hello.world <- function(i) {
  sprintf('Hello from loop iteration %d running on node %s',
          i, Sys.info()[c("nodename")]);
}

#library(Rmpi)
library(parallel)

#cl <- makeCluster( mpi.universe.size(), type='MPI' )
cl <- makeCluster(5)
  
output.lines <- parLapply( cl=cl, X=(1:1e4), fun=hello.world )
cat(unlist(output.lines), sep='\n')

stopCluster(cl)
#mpi.exit()
